import java.util.Arrays;

public class Main {

    //进制的转换

    //二进制转十进制
    public static void main1(String[] args) {
        int[] arr = {1,1,1,1,1};
        System.out.println(change(arr, 2, 5));
    }

    private static int change(int[] arr, int n, int len) {
        int w = 1;
        int ans = 0;
        for (int i = 0; i < len; i++) {
            ans += arr[i] * w;
            w *= n;
        }
        return ans;
    }

    //十进制转二进制
    public static void main(String[] args) {
        int[] arr = new int[15];
        change2(arr,2,2408);
        System.out.println(Arrays.toString(arr));
    }

    private static void change2(int[] arr, int n, int num) {
        int len = 0;
        while(num > 0){
            arr[len++] = num % n;
            num /= n;
        }
    }
    //100101101000
}
